<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>layui</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet"
	th:href="@{/manager/layui/lib/layui-v2.5.5/css/layui.css}"
	href="../../lib/layui-v2.5.5/css/layui.css" media="all">
<link rel="stylesheet" th:href="@{/manager/layui/css/public.css}"
	href="../../css/public.css" media="all">
<style>
body {
	background-color: #ffffff;
}
</style>
</head>
<body>
	<div class="layui-form layuimini-form">
		<input
			type="hidden" name="id" th:value="${user.id}">
		<div class="layui-form-item">
			<label class="layui-form-label required">用户名</label>
			<div class="layui-input-inline">
				<input type="text" name="username" lay-verify="required" th:value="${user.username}"
					lay-reqtext="用户名不能为空" placeholder="请输入用户名称" class="layui-input">

			</div>
		</div>
		
		<div class="layui-form-item">
			<label class="layui-form-label">昵称</label>
			<div class="layui-input-inline">
				<input type="text" name="nickname" class="layui-input" th:value="${user.nickname}" >
			</div>
		</div>
		
		<div class="layui-form-item" th:if="${user.password == null }">
			<label class="layui-form-label">密码<span style="font-size: 8px">（不填默认为123456）</span></label>
			<div class="layui-input-inline">
				<input type="password" name="password" class="layui-input" >
			</div>
		</div>
		
		<div class="layui-form-item">
			<label class="layui-form-label required">状态</label>
			<div class="layui-input-inline">
				<input type="radio" name="status" value="0" title="正常" th:value="${user.status}">
				<input type="radio" name="status" value="1" title="禁用" th:value="${user.status}">
			</div>
		</div>
		


		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn layui-btn-normal" lay-submit
					lay-filter="saveBtn">确认保存</button>
			</div>
		</div>
	</div>
	<!-- 	</form> -->
	<script th:src="@{/manager/layui/lib/layui-v2.5.5/layui.js}"
		src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
	<script>
		layui.use([ 'form' ], function() {
			var form = layui.form, layer = layui.layer, $ = layui.$;

			//监听提交
			form.on('submit(saveBtn)', function(data) {
				$.ajax({
					url : '/user/add',
					data : data.field,
					dataType : "json",
					success : function(result) {
						layer.alert("操作成功", function() {
							parent.window.location.reload();
						})

					}
				});

				return false;
			});

		});
	</script>
</body>
</html>